#include <iostream>
#include <vector>

using namespace std;

class Solution
{
public:
    int lengthOfLongestSubsequence(vector<int> &nums, int target)
    {
        vector<int> dp(target + 1, INT_MIN);
        dp[0] = 0;
        for (int i = 0; i < nums.size(); i++)
        {
            for (int j = target; j >= nums[i]; j--)
            {
                dp[j] = max(dp[j - nums[i]] + 1, dp[j]);
            }
        }
        return dp[target] > 0 ? dp[target] : -1;
    }
};

int main()
{
    cout << "Code2915" << endl;
    Solution s;
    vector<int> nums = {1, 2, 3, 4, 5};
    cout << s.lengthOfLongestSubsequence(nums, 9) << endl;
    return 0;
}